home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # No, this isn't generated by autoconf
- # Some parts are inspired by autoconf (Free Software Foundation), however
- # And the idea is slightly the same
-
- # Usage:
- # './configure' and then 'make' and 'make install', or
- # './configure --make --install'
-
- SHELL=/bin/sh
-
- ac_prev=
- for ac_option
- do
- # If the previous option needs an argument, assign it.
- if test -n "$ac_prev"; then
- eval "$ac_prev=\$ac_option"
- ac_prev=
- continue
- fi
-
- case "$ac_option" in
- -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
- *) ac_optarg= ;;
- esac
-
- case "$ac_option" in
-
- --pthread | --thread) THREADS=1 ;;
- --nopthread | --nothread) THREADS=0 ;;
-
- --longlong) LONGLONG=1 ;;
- --nolonglong) LONGLONG=0 ;;
-
- --inaddrt) NODECLINADDRT=0 ;;
- --noinaddrt) NODECLINADDRT=1 ;;
-
- --useuid) NOUID=0 ;;
- --nouseuid) NOUID=1 ;;
-
- --useftime) NOFTIME=0 ;;
- --nouseftime) NOFTIME=1 ;;
-
- --system=*) SYSTEMTYPE="$ac_optarg" ;;
- --system) ac_prev=SYSTEMTYPE ;;
-
- --debug) OTYPE="-O0 -g3" ;;
-
- --make) DOMAKE=1 ;;
- --install) DOINSTALL=1 ;;
- --cls)
- strip_cr *.c *.h
- rm -f httrack 2>/dev/null
- chmod 644 *.h *.c
- chmod u+w *
- exit
- ;;
- -bindir | --bindir | --bindi | --bind | --bin | --bi)
- ac_prev=bindir ;;
- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
- bindir="$ac_optarg" ;;
-
- --help)
- cat <<EOF
- --nopthread : do not use threads (pthread.h)
- --pthread : do use threads (pthread.h)
- --nolonglong : do not use 64-bit int
- --longlong : do use 64-bit int
- --noinaddrt : do not redeclare in_addr_t
- --inaddrt : do redeclare in_addr_t
- --nouseuid : do not use setuid()/setgid()
- --useuid : do use setuid()/setgid()
- --nouseftime : do not use ftime()
- --useftime : do use ftime()
- --system=<type> : override system type (uname) (types: 'Default','Linux','SunOS','AIX')
- --make : 'make' after configure
- --install : 'make install' after configure
- --debug : add debug information (for gdb)
- EOF
- exit
- ;;
-
- *) echo "Unrecognized option: $ac_option"
- exit
- ;;
-
- esac
-
- done
-
- echo "Welcome to HTTrack Website Copier!"
- echo "Type in ./configure --help for more details"
- echo "If this script fails, you can enter supplemental options through '--option=value'"
- echo "or enter in manual make, through 'make help'"
- echo ""
-
- if cp -f Makefile.in Makefile; then
-
- SEDEXEC=
-
- # System (OS) type?
- printf "Checking for OS type.. "
- if test -z "$SYSTEMTYPE"; then
- SYSTEMTYPE="`uname`"
- fi
- case "$SYSTEMTYPE" in
- SunOS) printf "SunOS/Solaris\n";
- PLATFORM=0
- SOLSOCK=1
- ;;
- AIX) printf "AIX\n"; PLATFORM=2 ;;
- *) printf "Linux type\n"; PLATFORM=3 ;;
- esac
-
- WTYPE="-Wall -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wnested-externs"
-
- if test -z "$OTYPE"; then
- OTYPE="-O3"
- fi
-
- # Binaries location
- if test -z "$BINPATH"; then
- printf "Checking for bin directory.. "
- if test -d "/usr/bin"; then
- BINPATH="/usr/bin"
- else
- BINPATH="/bin"
- fi
- printf "$BINPATH\n"
- else
- echo "Overriding BINPATH=$BINPATH"
- fi
-
- # Prefix location
- if test -z "$PREFIX"; then
- printf "Checking for usr directory.. "
- PREFIX="/usr"
- printf "$PREFIX\n"
- else
- echo "Overriding PREFIX=$PREFIX"
- fi
-
- # 64-bit (long long) cause some troubles to some processors
- # because some alignements aren't properly defined
- # we only accept 64-bit on tested processors here
- if test -z "$LONGLONG"; then
- printf "Checking for long long.. "
- LONGLONG=
- if grep "long long" /usr/include/sys/types.h >/dev/null; then
- if uname -a|grep -E ' i[3-9]86 ' >/dev/null; then
- LONGLONG=1
- fi
- fi
- if test -n "$LONGLONG"; then
- printf "supported\n"
- else
- printf "not tested/supported. Use --LONGLONG=1 to override\n"
- fi
- else
- echo "Overriding LONGLONG=$LONGLONG"
- fi
-
- # Do we not have to redeclare in_addr_t ?
- # Sometimes this type is defined, or not..
- if test -z "$NODECLINADDRT"; then
- printf "Checking for in_addr_t declaration in /usr/include/arpa/inet.h.. "
- if grep "in_addr_t" /usr/include/arpa/inet.h >/dev/null; then
- printf "found, do not redeclare\n"
- NODECLINADDRT=1
- else
- printf "not found, declaring\n"
- NODECLINADDRT=
- fi
- else
- echo "Overriding NODECLINADDRT=$NODECLINADDRT"
- fi
-
- # Sometimes, pthread.h doesn't exists on some systems
- # This is sad, because it speeds up some useful things, like DNS or ftp
- if test -z "$THREADS"; then
- printf "Checking for /usr/include/pthread.h.. "
- if test -f "/usr/include/pthread.h"; then
- if test -f "/usr/lib/libpthread.so"; then
- printf "found\n"
- THREADS=1
- else
- printf "library not found (too bad), no threads will be available\n"
- THREADS=
- fi
- else
- printf "not found, no threads will be available\n"
- THREADS=
- fi
- else
- echo "Overriding THREADS=$THREADS"
- fi
-
- # Sometimes, setuid and setgid can't be used (missing pwd.h and unistd.h ?!)
- if test -z "$NOUID"; then
- NOUID=1
- printf "Checking for /usr/include/pwd.h and /usr/include/unistd.h.. "
- if test -f "/usr/include/pwd.h"; then
- if test -f "/usr/include/unistd.h"; then
- NOUID=
- fi
- fi
- if test -z "$NOUID"; then
- printf "found\n"
- else
- printf "not found, not using setuid() and setgid()\n"
- fi
- else
- echo "Overriding NOUID=$NOUID"
- fi
-
- # Sometimes, ftime can't be used (missing declaration...)
- if test -z "$NOFTIME"; then
- NOFTIME=1
- printf "Checking for ftime in /usr/include/sys/timeb.h.. "
- if grep "extern int ftime" /usr/include/sys/timeb.h >/dev/null; then
- NOFTIME=
- fi
- if test -z "$NOFTIME"; then
- printf "found\n"
- else
- printf "not found (too bad), not using ftime()\n"
- fi
- else
- echo "Overriding NOFTIME=$NOFTIME"
- fi
-
- # Test variables
- if test "$NOUID" = 1; then
- SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEUID__/HTS_DO_NOT_USE_UID/'"
- fi
- if test "$NOFTIME" = 1; then
- SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEFTI__/HTS_DO_NOT_USE_FTIME/'"
- fi
- if test "$NODECLINADDRT" = 1; then
- SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEINA__/HTS_DO_NOT_REDEFINE_in_addr_t/'"
- fi
- if test "$THREADS" = 1; then
- SEDEXEC="$SEDEXEC | sed -e \"s/__CFLAGS__/$OTYPE $WTYPE -D_REENTRANT/g\""
- SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS__/-lpthread/g'"
- else
- SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEPTH__/HTS_DO_NOT_USE_PTHREAD/'"
- SEDEXEC="$SEDEXEC | sed -e \"s/__CFLAGS__/$OTYPE $WTYPE/g\""
- SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS__//g'"
- fi
- if test "$SOLSOCK" = 1; then
- SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS2__/-lnsl -lsocket/g'"
- else
- SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS2__//g'"
- fi
- if test ! "$LONGLONG" = 1; then
- SEDEXEC="$SEDEXEC | sed -e 's/__DEFINE64B__/HTS_NO_64_BIT/'"
- fi
- SEDEXEC="$SEDEXEC | sed -e \"s/__PLATFORM__/$PLATFORM/g\""
- SEDEXEC="$SEDEXEC | sed -e 's/#__AUTONAME__/AUTONAME = auto/'"
- SEDEXEC="$SEDEXEC | sed -e 's/#define __DEFINE.*__//g'"
- TMP=`echo $BINPATH | sed -e 's/\\//\\\\\\//g'`
- SEDEXEC="$SEDEXEC | sed -e \"s/#__BINPATH__/BINPATH = $TMP/g\""
- TMP=`echo $PREFIX | sed -e 's/\\//\\\\\\//g'`
- SEDEXEC="$SEDEXEC | sed -e \"s/#__PREFIX__/PREFIX = $TMP/g\""
-
- # Search for gmake
- printf "Checking for make.. "
- MAKEPATH=
- if test -f "/usr/bin/gmake"; then
- MAKEPATH=/usr/bin/gmake
- else
- if test -f "/bin/gmake"; then
- MAKEPATH=/bin/gmake
- else
- if test -f "/usr/local/bin/gmake"; then
- MAKEPATH=/usr/local/bin/gmake
- fi
- fi
- fi
- if test -n "$MAKEPATH"; then
- printf "found $MAKEPATH\n"
- else
- MAKEPATH=make
- printf "not found, assume make will work\n"
- fi
-
- # Sed strip_cr
- printf "Checking for perl.. "
- PERLPATH=
- cp -f strip_cr.in strip_cr
- if test -f "/usr/bin/perl"; then
- PERLPATH=/usr/bin/perl
- else
- if test -f "/bin/perl"; then
- PERLPATH=/bin/perl
- else
- if test -f "/usr/local/bin/perl"; then
- PERLPATH=/usr/local/bin/perl
- fi
- fi
- fi
- if test -n "$PERLPATH"; then
- printf "found $PERLPATH\nEnsuring that *.c/*.h source files don't contains CR (^M).. "
- TMP=`echo $PERLPATH | sed -e 's/\\//\\\\\\//g'`
- cat strip_cr | sed -e "s/__PERL__/$TMP/" > __tmp; mv __tmp strip_cr
- chmod 700 strip_cr
- ./strip_cr *.c *.h
- printf "done\n"
- fi
-
- # Sed all __VARS__
- CMD="cat Makefile $SEDEXEC > __tmp; mv __tmp Makefile"
- echo "Command: $CMD"
- if eval $CMD; then
-
- echo ""
- echo "Makefile created!"
- echo "Type in '$MAKEPATH' to build and '$MAKEPATH install' to install"
-
- if test -n "$DOMAKE"; then
- echo "Making.."
- eval $MAKEPATH clean
- eval $MAKEPATH
- fi
- if test -n "$DOINSTALL"; then
- echo "Installing.."
- eval $MAKEPATH install
- fi
-
- else
- echo "Error while seding Makefile.."
- fi
-
- else
- echo "Error copying Makefile.in -> Makefile.. giving up"
- fi
-
-